package com.线程;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.Date;
import java.util.concurrent.TimeUnit;

public class 线程中断 {


    public static void main(String[] args) throws InterruptedException {


     Thread t =    new Thread(()->{

            boolean b = true;
            while(b){
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    System.out.println("中断");
                 b  = false;
                }

                System.out.println(Thread.currentThread().getName()+"----"+new Date(System.currentTimeMillis()));







            }

        });

     t.start();;

        TimeUnit.SECONDS.sleep(10);

t.interrupt();

    }

}
